package main

import "fmt"

// 创建结构体
type AnimalInter interface {
	sing()
	getName() string
}

type Cat struct {
	Name string
}

type Dog struct {
	Name string
}

func (c Cat) sing() {
	fmt.Println(c.Name, "在唱歌")
}

func (c Cat) getName() string {
	return c.Name
}

func (c Dog) sing() {
	fmt.Println(c.Name, "在唱歌")
}
func (c Dog) getName() string {
	return c.Name
}

func sing(c AnimalInter) {
	//断言 判断接口对象是否是猫
	ch, ok := c.(Cat)
	fmt.Println(ch, ok)
	switch server := c.(type) {
	case Cat:
		fmt.Println(server)
	case Dog:
		fmt.Println(server)
	default:
		fmt.Println("我也不知道是个啥")
	}
	c.sing()
	//fmt.Println(c.getName())
}

//// 空接口
//type EmpytInter interface {
//}

//func Point(nn interface{}) {
//	fmt.Println("你好")
//}

func Point(nn any) {
	fmt.Println("你好")
}

func main() {
	var animal1 = Cat{Name: "cat"}
	var animal2 = Dog{Name: "dog"}
	sing(animal1)
	sing(animal2)
	Point(animal1)
}
